<?php

namespace App\Http\Controllers\Api;

use App\Services\AdvertisementService;
use App\Services\BrandService;
use App\Services\CategoryService;
use App\Services\ProductService;

// webapp 首页控制器
class IndexController extends Controller
{
    // 这里webapp的大部分内容   例子: http://demo.rageframe.com/api/tiny-shop/v1/index/index
    public function index(CategoryService $categoryService, ProductService $productService,
        AdvertisementService $advertisementService, BrandService $brandService)
    {
        // 1. search [hot_search_default 热点搜索, hot_search_list]

        $data['adv'] = $advertisementService->adv();

        // 3. brand品牌
        $data['brand'] = $brandService->get(10);

        // 4. product_hot 热点商品
        $data['product_hot'] = $productService->hotIndex(10, true);

        // 5. product_recommend 商品推荐
        $data['product_recommend'] = $productService->recommendIndex(10, true);

        // 6. product_new 最新商品
        $data['product_new'] = $productService->newIndex(10, true);

        // 7. guess_you_like 猜你喜欢
        $data['guess_you_like'] = $productService->guessYouLikeIndex(10, true);

        // 8. config 配置

        return $this->success($data);
    }
}
